﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for UpdateTag
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class UpdateTag : System.Web.Services.WebService
{

    public UpdateTag()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
    [WebMethod]
    public int InsertCategory(string Name, string Slug, int ParentId, string Des, string Taxonomy)
    {
        return Wp.BLL.TblTermTaxonomyManager.CreateInstant().InsertTag(Name, Slug, ParentId, Des, Taxonomy);
    }
    [WebMethod]
    public int DeleteTag(int Id)
    {
        try
        {
            Wp.DAL.TblTermTaxonomyEntity item = Wp.BLL.TblTermTaxonomyManager.CreateInstant().SelectOne(Id);
            Wp.BLL.TblTermTaxonomyManager.CreateInstant().UpdateParentOfChild(item.Id, item.ParentId);
            Wp.BLL.TblTermTaxonomyManager.CreateInstant().Delete(Id);
            return Id;
        }
        catch (Exception)
        {
            return -1;
        }

    }
    [WebMethod]
    public int InsertPost(string name, string url, int parentid, string des, string posttype)
    {
        return Wp.BLL.TblPostsManager.CreateInstant().InsertPost(name, url, parentid, des, posttype);
    }
    [WebMethod]
    public int DeletePost(int id)
    {
        try
        {
            Wp.DAL.TblPostsEntity item = Wp.BLL.TblPostsManager.CreateInstant().SelectOne(id);
            Wp.BLL.TblPostsManager.CreateInstant().UpdateParentOfChild(item.Id, item.ParentId);
            Wp.BLL.TblPostsManager.CreateInstant().Delete(id);
            return id;
        }
        catch (Exception)
        {
            return -1;
        }

    }
    [WebMethod]
    public int AddTag(int postid, string Name)
    {
        try
        {
            return Wp.BLL.TblTermTaxonomyManager.CreateInstant().InsertPostTag(postid, Name, "posttags");
            //Wp.DAL.TblPostsEntity item = Wp.BLL.TblPostsManager.CreateInstant().SelectOne(id);
            //Wp.BLL.TblPostsManager.CreateInstant().UpdateParentOfChild(item.Id, item.ParentId);
            //Wp.BLL.TblPostsManager.CreateInstant().Delete(id);
            //return id;
        }
        catch (Exception)
        {
            return -1;
        }

    }
    [WebMethod]
    public int DeleteTag(int postid, int tagid)
    {
        try
        {
            //Wp.DAL.TblPostsEntity item = Wp.BLL.TblPostsManager.CreateInstant().SelectOne(id);
            //Wp.BLL.TblPostsManager.CreateInstant().UpdateParentOfChild(item.Id, item.ParentId);
            //Wp.BLL.TblPostsManager.CreateInstant().Delete(id);
            //return id;
            return -1;
        }
        catch (Exception)
        {
            return -1;
        }

    }
}